﻿
// NetClientTestDlg.h: 头文件
//

#pragma once

#include "pbox.h"

class ptest_state
{
public:
	ptest_state() :n_plan(0), n_send(0), n_recv(0),n_error(0), n_ready(1), n_flag(0)
	{
	}
	PNetLink plink;
	unsigned long long n_stat[2];
	int n_plan;
	int n_send;
	int n_recv;
	int n_error;
	int n_ready;//就绪
	int n_flag;//启用
	inline void clear()
	{
		plink.clean();
		n_plan = 0;
		n_send = 0;
		n_recv = 0;
		n_error = 0;
		n_ready = 1;
		n_flag = 0;
	}
	inline bool ready()//可以发包
	{
		return  plink.isValid() && n_ready && (n_plan>0);
	}
};


// CNetClientTestDlg 对话框
class CNetClientTestDlg : public CDialogEx
{
// 构造
public:
	CNetClientTestDlg(CWnd* pParent = nullptr);	// 标准构造函数
	~CNetClientTestDlg();
// 对话框数据
#ifdef AFX_DESIGN_TIME
	enum { IDD = IDD_NETCLIENTTEST_DIALOG };
#endif

	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV 支持


// 实现
protected:
	HICON m_hIcon;
	PBoxRandom random;
	ptest_state* ptest;
	
	void recvTestPack(ptest_state& pt,const char* pdata,int length);
	void sendTestPack(ptest_state & pt);
	// 生成的消息映射函数
	afx_msg LRESULT OnReadMessage(WPARAM wParam, LPARAM lParam);
	//afx_msg LRESULT OnStatMessage(WPARAM wParam, LPARAM lParam);

	// 生成的消息映射函数
	virtual BOOL OnInitDialog();
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	DECLARE_MESSAGE_MAP()
public:
	afx_msg void OnTimer(UINT_PTR nIDEvent);
	afx_msg void OnBnClickedButton1();
	afx_msg void OnBnClickedButton2();
	afx_msg void OnBnClickedButton3();
	CComboBox m_combo_mode;
};
